package com.sc.nft.hna.form;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.sc.nft.config.hna.HnaConfig;
import com.sc.nft.dto.HnaCardBindConfirmDTO;
import com.sc.nft.mapstruct.HnaMapStruct;
import lombok.Data;

import java.util.Map;

@Data
public class R008TransForm extends BaseTransForm {

  public static final String[] encryptArr = new String[] {"ncountOrderId", "smsCode", "merUserIp"};
  public static final String[] verifyArr =
      new String[] {
        "version",
        "tranCode",
        "merOrderId",
        "merId",
        "charset",
        "signType",
        "resultCode",
        "errorCode",
        "bindCardAgrNo",
        "bankCode",
        "cardType",
        "shortCardNo"
      };
  public static final String[] submitArr =
      new String[] {
        "version",
        "tranCode",
        "merId",
        "merOrderId",
        "submitTime",
        "msgCiphertext",
        "signType",
        "signValue",
        "merAttach",
        "charset"
      };
  private static final long serialVersionUID = 1010207515702220296L;

  private String ncountOrderId; // 签约订单号
  private String smsCode; // 签约短信验证码
  private String merUserIp; // 商户用户IP

  public static final String MAIN_URL = "https://ncount.hnapay.com/api/r008.htm";
  public static final String TRAN_CODE = "R008";

  @Override
  public String getEncryptJsonStr() {
    return getJsonStr(this, encryptArr);
  }

  @Override
  public String getVerifyJsonStr() {
    return getJsonStr(this, verifyArr);
  }

  @Override
  public String getSubmitJsonStr() {
    return getJsonStr(this, submitArr);
  }

  public static Map<String, Object> generateParam(HnaConfig hnaConfig, HnaCardBindConfirmDTO dto) {
    R008TransForm transForm = HnaMapStruct.INSTANCE.dto2r008form(dto);
    transForm.initCommonParams(TRAN_CODE, hnaConfig.getMerId(), IdWorker.getIdStr(), "");
    return generateParam(transForm, hnaConfig);
  }
}
